package com.yourenbang.lingyun.transaction.web.controller.manage;

import com.yourenbang.lingyun.core.base.controller.BaseController;
import com.yourenbang.lingyun.core.base.interceptor.ExcludeInterceptor;
import com.yourenbang.lingyun.core.message.Result;
import com.yourenbang.lingyun.core.util.KLog;
import com.yourenbang.lingyun.transaction.web.domain.dto.manage.ManageWithdrawalReturnDTO;
import com.yourenbang.lingyun.transaction.web.service.fund.FundService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/transaction/manage/withdraw")
public class ManageWithdrawController extends BaseController {

    @Autowired
    private FundService fundService;

    /**
     * 归还冻结金额
     * @return
     */
    @ExcludeInterceptor
    @RequestMapping(value = "/return", method = RequestMethod.POST)
    public Result returnFund(@Validated @RequestBody ManageWithdrawalReturnDTO dto, BindingResult br) {
        KLog.info("【归还冻结金额】入参:{}", dto);
        Result verifyParam = verifyParam(br);
        if (!verifyParam.isSuccess()) {
            return verifyParam;
        }


        return fundService.cancelByFundAccountWithdrawPaymentId(Integer.valueOf(dto.getFundAccountWithdrawPaymentId()),dto.getPlatNo());
    }

}
